package org.example.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author: gx.wu
 * @create: 2023-05-09 15:21
 * @Description:
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class CommonResult<T> {
    private Integer code;
    private T data;
    private String msg;

    public static <T> CommonResult success(T data){
        return CommonResult.success(data, "成功");
    }

    public static <T> CommonResult success(T data, String msg){
        return new CommonResult(0, data, msg);
    }

    public static <T> CommonResult fail(T data){
        return CommonResult.fail(data, "失败");
    }

    public static <T> CommonResult fail(T data, String msg){
        return new CommonResult(-1, data, msg);
    }
}
